print("Lua main script")
print("Main loop")

ImageLocs = {}

while (isrunning())
do
	local e
	e = next_event()
	if e[1] == "quit" then
		quit()
	elseif (e[1] == "keydown") then
		if e[2] < 256 and string.char(e[2]) == 'q' then
			quit()
		end
	elseif (e[1] == "mousedown") then
		if (e[2] == 1) then
			for i = 0, 1280, 80 do
			for j = 0, 1024, 80 do
				ident = addimage("Grass.png", i, j, 80, 80)
				ImageLocs[ident] = {i,j}
			end end
		elseif (e[2] == 3) then
			for k,v in pairs(ImageLocs)
			do
				delimage(k)
			end
			ImageLocs = {}
		end
	end
	delay()
end

quit()

